<?php

class News_model extends CI_Model {


    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function news_post($news_title,$category,$location,$featured,$caption,$content,$posted_on)
    {
        $data = array(
           'id'                 => 'NULL' ,
           'featured_status'    => 'NULL' ,
           'news_title'         => $news_title,
           'caption'            => $caption,
           'content'            => $content,
           'posted_by'          => 'Admin',
           'posted_on'          => $posted_on,
           'rating'             => 'NULL',
           'category_id'        => $category,
           'location'           => $location
        );

        $query = $this->db->insert('news', $data);
        if ($query)  return 1;
        else return 0;
    }

    function news_list()
    {
         return $this->db->get('news')->result();
       
    }
    function news_select($id)
    {
        return $this->db->get_where('news', array('id' => $id))->row();

    }
    function delete($id)
    {
        $query = $this->db->delete('news', array('id' => $id));
        if($query)
            return 1;
        else
            return 0;
    }

        function news_update($news_title,$category,$location,$featured,$caption,$content,$posted_on)
    {
        $data = array(
           'id'                 => 'NULL' ,
           'featured_status'    => 'NULL' ,
           'news_title'         => $news_title,
           'caption'            => $caption,
           'content'            => $content,
           'posted_by'          => 'Admin',
           'posted_on'          => $posted_on,
           'rating'             => 'NULL',
           'category_id'        => $category,
           'location'           => $location
        );
        $this->db->where('id', $id);
        $this->db->update('news', $data);
        if ($query)  return 1;
        else return 0;
    }


}
    ?>